package paper.xml;

import javax.xml.parsers.*;
import org.xml.sax.helpers.*;
import org.xml.sax .*;
import java.io.*;
import org.xml.sax.helpers.DefaultHandler;
import java.util.*;

import paper.xml.SurroundStream;
import paper.xml.CiteseerParser;
import paper.xml.DblpParser;
import paper.xml.PaperSet;

class PaperBase
{
//static Paper[] papers;
//static Person[] people;
//static Comment[] comments;

    public static void main(String[] arse) throws ParserConfigurationException,SAXException,IOException
    {
        SAXParserFactory factory = SAXParserFactory.newInstance();
        SAXParser parser = factory.newSAXParser();

        PaperSetHash set = new PaperSetHash();
        try {
            File baseDir = new File("/space/moss/raw-sources/");
            File cite = new File(baseDir,"WHOLETHING");
            File dblp = new File(baseDir,"dblp.xml");
            parser.parse( new SurroundStream(cite), new CiteseerParser(set));
            set.dumpHash();
            //parser.parse( new BufferedInputStream( new FileInputStream(dblp)), new DblpParser(set));

        } catch (SAXParseException se)
        {
            System.out.println("Error: " + se.toString() + " at line " + se.getLineNumber());
        } 
    }
/*
    static void dump()
    {
        int i;
        System.out.println("digraph{");
        for(i=0; i<5; i++)
        {
            System.out.print("paper" + i + " [label=");
            System.out.println('"' + papers[i].name + " =" + papers[i].score + "\"];");
        }
        for(i=0; i<5; i++)
        {
            System.out.print("person" + i + " [color=green,label=");
            System.out.println('"' + people[i].name + "\"];");
        }
        for(i=0; i<5; i++)
        {
            int j;
            for(j=0; j<2; j++)
            {
                if( papers[i].cites[j] != -1 )
                    System.out.println("paper"+i+" -> paper"+papers[i].cites[j]+";");
            }
        }
        for(i=0; i<5; i++)
        {
            System.out.println("person" + papers[i].author + " -> paper" + i + " [style=dotted];");
        }
        for(i=0; i<5; i++)
        {
            System.out.println("comment" + i + " [color=red,label=\"" + comments[i].body + "\"];");
            System.out.println("person" + comments[i].author + " -> comment" +
                               i + " [style=dotted];");
            if( comments[i].targetType == 1 )
            {
                System.out.println("comment" + i + " -> paper" + comments[i].topic + ";");
            }
            else
            {
                System.out.println("comment" + i + " -> comment" + comments[i].topic + ";");   
            }
                               
        }
    
        System.out.println("}");
    }*/
}
